import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:honeypotflutter/modules/cabinet/pages/cabinet_form_earnings_info/view.dart';
import 'package:honeypotflutter/public/public_date.dart';
import 'package:honeypotflutter/publicBussine/bussine_colors.dart';
import '../model/cabinet_form_earnings_model.dart';

class CabinetFormEarningsItem extends StatelessWidget {
  final CabinetFormEarningsModel? model;
  final Color? color;
  final Color? backColor;
  const CabinetFormEarningsItem({
    super.key,
    this.model,
    this.color,
    this.backColor,
  });

  @override
  Widget build(BuildContext context) {
    return InkWell(
      child: Container(
        decoration: BoxDecoration(
          color: (backColor != null) ? backColor : MGColors.backColor,
          borderRadius: BorderRadius.circular(6),
        ),
        child: Flex(
          direction: Axis.horizontal,
          children: [
            Expanded(
                flex: 1,
                child: Container(
                  padding: EdgeInsets.only(top: 20, bottom: 20, left: 16, right: 16),
                  child: Text(
                    (model != null) ? HLDate.hl_format(date: model?.date ?? "", type: DateType.YYMMDD) : "日期",
                    style: TextStyle(color: color ?? MGColors.text3Color),
                  ),
                )),
            Expanded(
                flex: 2,
                child: Text(
                  (model != null) ? (model?.totalIncome ?? 0.0).toStringAsFixed(2) : "总收益",
                  textAlign: TextAlign.center,
                  style: TextStyle(color: color ?? MGColors.text3Color),
                )),
          ],
        ),
      ),
      onTap: () {
        if (model == null) {
          return;
        }
        Get.to(
          CabinetFormEarningsInfoPage(),
          arguments: {"date": HLDate.hl_format(date: model!.date ?? "", type: DateType.YYMMDD)},
        );
      },
    );
  }
}
